package com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00107;

import com.example.modelviewpresenter.Model.BasterModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00108.BaseDay00108Api;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00108.BaseDay00108Bean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00108.BaseDay00108Callbck;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00108.BaseDay00108Contion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00108.BaseDay00108Okhttp;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 作者:二徒
 * 时间：2021/10/27- 9:18
 * 功能实现：
 */
public class BaseDay00107Model extends BasterModel implements BaseDay00107Contion.moder {
    @Override
    public void getmoder(String name, BaseDay00107Callbck callbck) {
        BaseDay00107Okhttp.getOkhttp().getRetrofit().create(BaseDay00107Api.class).get007(name)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.computation())
                .subscribe(new Observer<BaseDay00107Bean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(BaseDay00107Bean baseDay00107Bean) {
                        List<BaseDay00107Bean.DataBean> dataBeans = baseDay00107Bean.getData();
                        callbck.suees(dataBeans);
                    }

                    @Override
                    public void onError(Throwable e) {
                        callbck.filai("失败");
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
